/*
 * Copyright (c) 2016-2017 fulihui.com All right reserved
 * Project: integral-business-parent
 * File name: BeansConfig.java
 */
package com.fulihui.integralbusiness.config;

import com.fulihui.integralbusiness.consumer.ZbusIntegralBusinessConsumer;
import com.fulihui.integralbusiness.handler.IntegralBusinessSelector;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;

/**
 * @author Willard.Hu on 2017/4/21 0021.
 */
@Configuration
public class SpringConfig {
    @Autowired
    private Environment environment;

    @Bean
    public IntegralBusinessSelector integralBusinessSelector() {
        return new IntegralBusinessSelector();
    }

    @Bean
    public ZbusIntegralBusinessConsumer zbusIntegralBusinessConsumer(IntegralBusinessSelector selector) {
        ZbusIntegralBusinessConsumer consumer = new ZbusIntegralBusinessConsumer();
        consumer.setSelector(selector);
        consumer.setAddress(environment.getProperty("fulihui.zbusAddress"));
        return consumer;
    }
}
